Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
'using facebook.desktop;
Imports facebook.Schema
Imports facebook.test.Properties
Imports facebook.desktop

Namespace facebook.test
	Partial Public Class FriendViewer
		Inherits Form
		Public Sub New()
			InitializeComponent()
			facebookService1.ApplicationKey = My.Settings.Default.api_key
			facebookService1.Secret = My.Settings.Default.secret
			facebookService1.ConnectToFacebook()
		End Sub

		Private Sub TestService_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
			ListenToEvents(True)
			Try
				Dim friends = facebookService1.friends.getUserObjects()
				Dim [me] = facebookService1.users.getInfo()
				LoadUserBasedControls([me])
				friendList1.Friends = friends
			Catch ex As Exception
				MessageBox.Show(ex.Message)
				Close()
			End Try
		End Sub

		Private Sub ListenToEvents(ByVal listen As Boolean)
			If listen Then
				AddHandler friendList1.FriendSelected, AddressOf friendList1_FriendSelected
			End If
		End Sub

		Private Sub friendList1_FriendSelected(ByVal sender As Object, ByVal e As FriendSelectedEventArgs)
			LoadUserBasedControls(e.User)
		End Sub

		Private Sub LoadUserBasedControls(ByVal user As user)
			profile1.User = user
			photoAlbum1.Albums = facebookService1.photos.getAlbums(user.uid)
		End Sub
	End Class
End Namespace